package javawdw.security.spi;

import java.text.SimpleDateFormat;

import javawdw.security.entity.User;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

public class IService {
	protected SimpleDateFormat timstampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	protected SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	protected String SUCCESS = "{\"result\":\"success\"}";
	protected String FAILURE = "{\"result\":\"failure\"}";
	public UserDetails getCurrentUser() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		if (authentication != null) {
			try {
				return (User) authentication.getPrincipal();
			} catch (Exception e) {
			}
		}
		return null;
	}
}